package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.ZCzxfunds;
import com.hbnu.system.service.ZCzxfundsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ZCzxfunds")
@Api(tags = "纵向支出经费相关模块")
public class ZCzxfundsController {
    @Autowired
    ZCzxfundsService zczxfundsService;

    @ApiOperation("支出经费添加")
    @PostMapping("/addZCfunds")
    public Rest<Boolean> AddZCfunds(@RequestBody ZCzxfunds zcfunds){
        boolean add = zczxfundsService.addZCzxfundsProject(zcfunds);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("支出经费删除")
    @GetMapping("/removeZCfunds")
    public Rest<Boolean> RemoveZCfunds(String id){
        boolean remove= zczxfundsService.removeZCzxfundsProject(id);
        return remove ? Rest.success() : Rest.failed();
    }
    @ApiOperation("支出经费更新")
    @PostMapping("/UpdateZCfunds")
    public Rest<Boolean> UpdateZCfunds(@RequestBody ZCzxfunds zcfunds){
        boolean update = zczxfundsService.updateZCzxfundsProject(zcfunds);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("支出经费-通过纵向项目id查询")
    @GetMapping("/GetZCfundsByTranprojectID")
    public Rest<List<ZCzxfunds>> GetZCfundsByTranprojectID(String tranID){
        List<ZCzxfunds> paperProjectByPaperID = zczxfundsService.getZCzxfundsByPorprojectID(tranID);
        return Rest.success(paperProjectByPaperID);
    }
}
